<template>
    <div class="discuss-main">
        <div class="box2"  v-for="(ccBean,index) in ParentComment" :key="index">
            <div class="box3">
                <div>
                    <img :src="imgUrl[ccBean.user.imgCode]" alt="" width="60px" height="60px">
                </div>
                <div class="name">{{ccBean.user.name}}</div>
            </div>
            <div class="box4">
                <div class="text">{{ccBean.text}}</div>
                <div class="time">
                <span>{{ccBean.formatCreateTime}}</span>
                </div>
                <div class="replyBox" 
                v-if="ccBean.commentChildList && ccBean.commentChildList.length > 0"
                >
                    <DiscussReply :ReplyChildComment="ccBean.commentChildList"></DiscussReply>
                </div>
                <div 
                    class="replyBox" 
                    v-else 
                    style="height: 0;"
                ></div>
                <div class="hr"></div>
            </div>
        </div>
    </div>
</template>

<script>
import DiscussReply from '../components/DiscussReply.vue'
import dayjs from 'dayjs'
export default {
    props:{
        photo:{
            type:Array,
            default:[]
        },
        MainParentComment:{
            type:Array
        }
    },
    data(){
        return{
            comment:[],
            imgUrl:['/images/1.jpg','/images/1.jpg','/images/2.jpg','/images/3.jpg','/images/4.jpg','/images/5.jpg','/images/6.jpg']
        }
    },
    components:{
        DiscussReply
    },
    computed:{
        ParentComment(){
            return this.MainParentComment.map(ccBean => {
                return {
                    ...ccBean,
                    formatCreateTime: dayjs(ccBean.createTime).format('YYYY-MM-DD HH:mm')
                }
            })
        }
    }
}
</script>

<style scoped>
    .discuss-main{
        display: flex;
        width: 80vw;
        min-height: 256px;
        margin: 0 auto;
        flex-direction: column;
        flex-wrap: wrap;
        flex: 0 1 auto;
    }
    .discuss-main  .box2 div img{
        width: 60px;
        height: 60px;
        border-radius: 30px;
    }
    .discuss-main .box2 .box3{
        width: 40vw;
        display: flex;
        flex-direction: row;
    }
    .discuss-main .box2{
        width: 40vw;
        height: auto;
        min-height: 150px;
        padding-left: 5px;
        /* display: flex; */
        flex-direction: column;
        align-items: stretch;
        box-sizing: border-box;
        flex-grow: 1;
    }
    .discuss-main .box2 .box4{
        width: 40vw;
        padding-left: 80px;
        margin-top: -30px;
        flex-grow: 1;
    }
    .discuss-main .box2 .box3 .name{
        padding-top: 15px;
        padding-left: 20px;
        font-size: 15px;
        color: #7f8388;
    }
    .discuss-main .box2 .text{
        width: 40vw;
        padding-top: 15px;
    }
    .discuss-main .box2 .time{
        padding-top: 5px;
        margin-bottom: 10px;
        font-size: 12px;
        color: #bec1c6;
    }
    .discuss-main .box2 .time a{
        padding-left: 16px;
        color: #bec1c6;
        text-decoration: none;
    }
    .discuss-main .box2 .hr{
        width: 600px;
        padding-left: 25px;
        border-bottom: 1px solid #e3e5e7;
    }
    .replyBox{
        width: 40vw;
        height: auto;
    }
</style>